using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using CodeStory.Core.ObjectBusiness;

namespace CodeStory.Gallery
{

	public class GallerySettingAttribute:Attribute
	{
	}
	/// <summary>
	/// 
	/// </summary>
	public sealed class GallerySetting
	{
		private static GallerySetting current;

		private bool allowCreateGallery = false;
		private string rootFolderPath = "CodeStoryGallery";
		int maxImageWidth = 600;
		

		[GallerySetting]
		[Description("Whether allow create gallery.")]
		public bool AllowCreateGallery {
			get { return allowCreateGallery; }
			set { allowCreateGallery = value; }
		}
		[GallerySetting]
		[Description("Set the root folder path of the gallery image.")]
		public string RootFolderPath {
			get { return rootFolderPath; }
			set { rootFolderPath = value; }
		}

		#region Save & Read
		static readonly object helpobject = new object();
		public static GallerySetting Current {
			get {
				lock (helpobject) {
					if (current == null) {
						current = new GallerySetting();
						string name = "gallery";
						SiteSettingBusiness.LoadObject(name, current);
					}
				}
				return current;
			}
		}

		public void Reset() {
			current = null;
		}

		public void Save() {
			SiteSettingBusiness.SaveObject("gallery", this);
		}
		#endregion
	}
}
